package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;

import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**

 * @Author: Learner
 * @Version: 1.0
 */
@Service
public class NursingLevelServiceImpl implements NursingLevelService {
    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    //查询所有护理等级
    @Override
    public List<NursingLevelVo> getListAll() {
        List<NursingLevelVo> nursingLevelVos = nursingLevelMapper.getListAll();
        return nursingLevelVos;
    }
    //新增
    @Override
    public void addNursingLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel =new NursingLevel();
        BeanUtils.copyProperties(nursingLevelDto,nursingLevel);
        nursingLevelMapper.addNursingLevel(nursingLevel);
    }

    @Override
    public PageResponse<NursingLevelVo> listByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingLevelVo> nursingLevelVos=nursingLevelMapper.listByPage(name ,status);
        return PageResponse.of(nursingLevelVos,NursingLevelVo.class);

    }

    //3.4根据id查询
    @Override
    public NursingLevelVo getById(long id) {
        return nursingLevelMapper.getById(id);
    }

    @Override
    public void updateNursringLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel=new NursingLevel();
        BeanUtils.copyProperties(nursingLevelDto,nursingLevel);
        nursingLevelMapper.updateNursringLevel(nursingLevel);
    }

    @Override
    public void delById(long id) {
        nursingLevelMapper.delById(id);

    }

    @Override
    public void updateStatus(long id, Integer status) {
        nursingLevelMapper.updateStatus(id,status);
    }


}
